import {
	request
} from '../utils/request.js'
import store from '../store'
import {
	Toast,
	Jump
} from '../utils/tools.js'
import {
	AESencrypt
} from "@/libs/fn/mima.js"
import {
	balance,
	UserInfo
} from '@/api/Users.js'

// 设备全网数据
export async function CreaditDay(params) {
	try {
		let res = await request({
			url: '/Trade/CreaditDay',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return false
	}
}

// 柱状图
export async function creaditDay7(params) {
	try {
		let res = await request({
			url: '/Trade/creaditDay7',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return false
	}
}

// 奖励条件查询
export async function myareatt(params) {
	try {
		let res = await request({
			url: '/Trade/myareatt',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return false
	}
}

// 获取转账地址
export async function GetTransferAccount() {
	try {
		let res = await request({
			url: '/Trade/GetTransferAccount',
			method: "post",
		})
		return res
	} catch (e) {
		return false
	}
}

//转让
export async function Transfer(params) {
	try {
		params.paypassword = AESencrypt(params.paypassword);
		let res = await request({
			url: '/Trade/Transfer',
			method: "post",
			data: params
		})
		if (res.success) {
			await balance()
		}
		return res
	} catch (e) {
		return false
	}
}

//提币
export async function WithdrawChain(params) {
	try {
		params.paypassword = AESencrypt(params.paypassword);
		let res = await request({
			url: '/Trade/WithdrawChain',
			method: "post",
			data: params
		})
		if (res.success) await balance()
		return res
	} catch (e) {
		return false
	}
}

//兑换申请
export async function WithdrawApply(params) {
	try {
		params.paypassword = AESencrypt(params.paypassword);
		let res = await request({
			url: '/Trade/WithdrawApply',
			method: "post",
			data: params
		})
		if (res.success) {
			await balance()
		}
		return res
	} catch (e) {
		return false
	}
}

//兑换申请记录
export async function GetWithdrawApply(params) {
	try {
		let res = await request({
			url: '/Trade/GetWithdrawApply',
			method: "post",
			data: params
		})
		return res
	} catch (e) {
		return false
	}
}

//兑换申请记录
export async function GetWithdrawChain(params) {
	try {
		let res = await request({
			url: '/Trade/GetWithdrawChain',
			method: "post",
			data: params
		})
		return res
	} catch (e) {
		return false
	}
}

//资金记录
export async function GetUserBalanceRecord(params) {
	try {
		let res = await request({
			url: '/Trade/GetUserBalanceRecord',
			method: "post",
			data: params
		})
		return res
	} catch (e) {
		return false
	}
}

export async function ReceiveAnti() {
	try {
		let res = await request({
			url: '/Trade/ReceiveAnti',
			method: "post",
		})
		if (res.success) {
			await balance()
		} else {
			Toast(res.msg)
		}
		return res
	} catch (e) {
		return false
	}
}

export async function Gethpuserday(params) {
	try {
		let res = await request({
			url: '/Trade/Gethpuserday',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return false
	}
}

export async function activetop(params) {
	try {
		let res = await request({
			url: '/Trade/activetop',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return []
	}
}

// 获取转让 资产
export async function getCanTransferCoins(params) {
	try {
		let res = await request({
			url: '/Trade/getCanTransferCoins',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return []
	}
}

// 
export async function BindBankCard(params) {
	try {
		let res = await request({
			url: '/Trade/BindBankCard',
			method: "post",
			params
		})
		if (res.success) {
			await UserInfo();
		}
		return res
	} catch (e) {
		return []
	}
}

// 全网数据
export async function GetBalanceTotla(params) {
	try {
		let res = await request({
			url: '/Trade/GetBalanceTotla',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return []
	}
}

// 线下充值登记
export async function tbvRegister(params) {
	try {
		let res = await request({
			url: '/Trade/tbvRegister',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return []
	}
}
// 我的线下充值记录
export async function Getutb(params) {
	try {
		let res = await request({
			url: '/Trade/Getutb',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return []
	}
}


// 权益积分  价格曲线
export async function GetDaytotal(params) {
	try {
		let res = await request({
			url: '/Trade/GetDaytotal',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return []
	}
}


// 权益积分 回购 兑换
export async function buyback(params) {
	try {
		params.paypassword = AESencrypt(params.paypassword);
		let res = await request({
			url: '/Trade/buyback',
			method: "post",
			params
		})
		if (res.success) {
			await balance()
		}
		return res
	} catch (e) {
		return []
	}
}

// 权益积分 回购 记录
export async function GetBuyBackRecored(params) {
	try {
		let res = await request({
			url: '/Trade/GetBuyBackRecored',
			method: "post",
			params
		})
		return res
	} catch (e) {
		return []
	}
}



// 收益 日统计
export async function creditDay(params) {
	try {
		let res = await request({
			url: '/Trade/creditDay',
			method: "post",
			data:params
		})
		return res
	} catch (e) {
		return []
	}
}
// 收益明细
export async function creditdetal(params) {
	try {
		let res = await request({
			url: '/Trade/creditdetal',
			method: "post",
			data:params
		})
		return res
	} catch (e) {
		return []
	}
}

// 奖励类型汇总
export async function creditTotal(params) {
	try {
		let res = await request({
			url: '/Trade/creditTotal',
			method: "post",
			data:params
		})
		return res
	} catch (e) {
		return []
	}
}